<div class="container-fluid">
    <h4>项目列表</h4>
    <div class="table-wrapper users-table section">
        <div class="row-fluid head">
        </div>
        <div class="input-group" id="search">
            <label for="mainName">维修人员:</label>
            <input type="text" name="mainName" class="input-small" id="mainName">
            <label for="mainMobile">维修人员电话:</label>
            <input type="text" name="mainMobile" class="input-small" id="mainMobile">

            <label for="status">状态：</label>
            <select id="status" name="status">
                <option value="-1">请选择</option>
                <option value="0">新提交</option>
                <option value="1">已审核</option>
                <option value="2">已维修</option>
                <option value="9">已办结</option>
            </select>

            维修日期：
            <input class="date-picker input-small" name="sdate" type="text"
                   data-date-format="yyyy-mm-dd"/>
            <i class="icon-calendar bigger-110"></i>至
            <input class="date-picker input-small" name="edate" type="text"
                   data-date-format="yyyy-mm-dd"/>
            <i class="icon-calendar bigger-110"></i>
            
            <span>
           <button id="search_btn" type="button" class="btn btn-purple btn-sm">
               搜索
               <i class="icon-search icon-on-right bigger-110"/>
           </button>
                 <button id="search_down" type="button" class="btn btn-purple btn-sm">
               <i class="icon-search icon-on-right bigger-110"></i>
               导出
           </button>
       </span>
        </div>
        <div id="list"></div>
    </div>
</div>

<script>
    var url = 'task/list-data.do';
    var $datagrid = $('#list');

    loadData();

    $('#search_btn').on('click', function () {
        loadData();
    });

    $('#search_down').click(function () {
        $.download({
            url: 'task/download.do',
            data: getCommJosnParams('search')
        });
    });

    function loadData() {
        $datagrid.datagrid({
            checkbox: false,
            'dataModel': {
                'url': url,
                'parameters': getCommJosnParams('search')
            },
            'columns': [
                {title: '项目名称', dataField: 'project'},
                {title: '地点', dataField: 'area'},
                {title: '详情', dataField: 'detail'},
                {title: '报修人', dataField: 'name'},
                {title: '报修人电话', dataField: 'mobile'},
//                    {title: '维修人员ID', dataField: 'mainId'},
                {title: '状态', dataField: 'stateDict'},
                {
                    title: '评价', dataField: 'evaluate', render: function (rec) {
                    if (rec.evaluate == undefined || rec.evaluate == '') {
                        return '';
                    } else {
                        return '<div class="evaluteSpan" title="' + rec.evaluate + '">' + rec.evaluate + '</div>';
                    }
                }
                },
                {title: '审核人', dataField: 'sureInfo'},
                {title: '维修人', dataField: 'mainInfo'},
                {title: '办结人', dataField: 'overInfo'},
                {title: '时间', dataField: 'createTime'},
                {
                    title: '详情', render: function (rec) {
                    return '<a onclick="javascript:toDetail(' + rec.id + ')">详情</a>'
                }
                }
            ]
        });
    };

    $('.date-picker').datepicker({
        language: 'zh-CN',
        autoclose: true,
        format: 'yyyy-mm-dd'
    }).next().on(ace.click_event, function () {
        $(this).prev().focus();
    });

    $('.datetime-picker').datetimepicker({
        language: 'zh-CN',
        autoclose: true,
        format: 'yyyy-mm-dd hh:ii:ss'
    }).next().on(ace.click_event, function () {
        $(this).prev().focus();
    });

    function toDetail(id) {
        var url = '/task/detail.do?id=' + id;
        loadPage(url);
    }
</script>
